﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Audit_Configuration_Oracle.DAL;
using System.Data;
using System.Windows.Forms;

namespace Audit_Configuration_Oracle.Controllers
{
    public class AuditRulesController
    {
        public static List<Dictionary<string, string>> GetAuditModalities()
        {
            List<Dictionary<string, string>> modalities = null;
            try
            {
                modalities = AuditRulesDAL.GetAuditModalities();
            }
            catch (Exception e)
            {
                throw e;
            }
            return modalities;
        }

        public static DataSet GetActiveRules(string targetTable, string user)
        {
            DataSet ds = null;
            try
            {
                switch (targetTable)
                {
                    case "Sentencias":
                        {
                            ds = AuditRulesDAL.GetActiveRulesStatements(user);
                            break;
                        }
                    case "Privilegios":
                        {
                            ds = AuditRulesDAL.GetActiveRulesPrivilegies(user);
                            break;
                        }
                    case "Objetos":
                        {
                            ds = AuditRulesDAL.GetActiveRulesObjects(user);
                            break;
                        }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            return ds;
        }

        public static bool DeactiveAuditRules(List<DataGridViewRow> lstRows)
        {
            return AuditRulesDAL.DeactiveAuditRules(lstRows);             
        }

        public static bool DeactiveObjectAuditRules(string target, List<string> rules)
        {
            bool res = false;
            try
            {
                res = AuditRulesDAL.DeactiveObjectAuditRules(target,rules);
            }
            catch (Exception e)
            {
                throw e;
            }
            return res;
        }
        
    }
}
